/*     */ package com.lmpop.frame.util;
/*     */ 
/*     */ import java.io.BufferedReader;
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.FileNotFoundException;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.io.InputStreamReader;
/*     */ import java.io.PrintStream;
/*     */ import java.io.UnsupportedEncodingException;
/*     */ import java.util.Arrays;
/*     */ import java.util.Hashtable;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class FileUtil
/*     */ {
/*     */   public Map getConfigString(String configName)
/*     */   {
/*  19 */     Map resultMap = new Hashtable();
/*  20 */     Config config = new Config();
/*  21 */     String rootPath = config.getString("rootpath");
/*  22 */     String fileName = rootPath + configName;
/*     */ 
/*  24 */     InputStream is = null;
/*     */     try {
/*  26 */       is = new FileInputStream(new File(fileName));
/*     */     } catch (FileNotFoundException e) {
/*  28 */       e.printStackTrace();
/*     */     }
/*     */ 
/*  31 */     String a1 = ""; String a2 = ""; String result = "";
/*  32 */     String line = "";
/*  33 */     BufferedReader reader = null;
/*  34 */     reader = new BufferedReader(new InputStreamReader(is));
/*     */     try
/*     */     {
/*  37 */       line = reader.readLine();
/*     */     } catch (IOException e) {
/*  39 */       e.printStackTrace();
/*     */     }
/*     */ 
/*  42 */     int i = 1;
/*  43 */     while (line != null) {
/*  44 */       if (i % 2 == 0)
/*  45 */         a2 = line;
/*     */       else {
/*  47 */         a1 = line;
/*     */       }
/*  49 */       if (getKey(a2).length() > 0) {
/*  50 */         if (a1.indexOf("#") > -1) {
/*  51 */           result = a1.replace("#", "");
/*     */           try {
/*  53 */             result = new String(result.getBytes(), "UTF-8");
/*     */           } catch (UnsupportedEncodingException e) {
/*  55 */             e.printStackTrace();
/*     */           }
/*     */         }
/*  58 */         if (i % 2 == 0)
/*  59 */           resultMap.put(getKey(a2).trim(), result.trim());
/*     */       }
/*     */       try
/*     */       {
/*  63 */         line = reader.readLine();
/*     */       } catch (IOException e) {
/*  65 */         e.printStackTrace();
/*     */       }
/*     */ 
/*  68 */       i++;
/*     */     }
/*     */     try
/*     */     {
/*  72 */       reader.close();
/*  73 */       is.close();
/*     */     } catch (IOException e) {
/*  75 */       e.printStackTrace();
/*     */     }
/*  77 */     System.out.println(resultMap);
/*  78 */     return resultMap;
/*     */   }
/*     */ 
/*     */   public String getKey(String proString)
/*     */   {
/*  83 */     String result = "";
/*  84 */     if (proString.indexOf("=") == -1)
/*  85 */       return "";
/*  86 */     String[] proStr = proString.split("=");
/*  87 */     if (proStr.length > 1)
/*  88 */       result = proStr[0];
/*  89 */     return result;
/*     */   }
/*     */ 
/*     */   public static void main(String[] args) {
/*  93 */     sortComparator("D:\\soft\\apache-tomcat-6.0.32\\webapps\\zlcms\\templets\\html\\default");
/*     */   }
/*     */ 
/*     */   public static File[] sortComparator(String filepath)
/*     */   {
/*  98 */     File dir = new File(filepath);
/*     */ 
/* 100 */     File[] files = dir.listFiles();
/*     */ 
/* 102 */     Arrays.sort(files, new FileUtils.CompratorByFileType());
/*     */ 
/* 104 */     System.out.print("sort by last modified: ");
/*     */ 
/* 106 */     for (int i = 0; i < files.length; i++)
/*     */     {
/* 108 */       System.out.println(files[i] + " ");
/*     */     }
/* 110 */     System.out.println();
/* 111 */     return files;
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.frame.util.FileUtil
 * JD-Core Version:    0.6.0
 */